package com.bluetrum.devicemanager.models;

import androidx.annotation.Nullable;

public class LeAudioBisItem {

    public static final byte TYPE_IDENTIFIER            = 0x01;
    public static final byte TYPE_BROADCAST_ADDRESS     = 0x02;
    public static final byte TYPE_RSSI                  = 0x03;
    public static final byte TYPE_BROADCAST_NAME        = 0x04;
    public static final byte TYPE_PROGRAM_INFO          = 0x05;
    public static final byte TYPE_CONNECTION_STATUS     = 0x06;

    private final int identifier;
    @Nullable
    private final byte[] broadcastAddressBytes;
    @Nullable
    private final Integer rssi;
    @Nullable
    private final String broadcastName;
    @Nullable
    private final String programInfo;
    @Nullable
    private final Boolean connected;

    public LeAudioBisItem(
            int identifier,
            @Nullable byte[] broadcastAddressBytes,
            @Nullable Integer rssi,
            @Nullable String broadcastName,
            @Nullable String programInfo,
            @Nullable Boolean connected
    ) {
        this.identifier = identifier;
        this.broadcastAddressBytes = broadcastAddressBytes;
        this.rssi = rssi;
        this.broadcastName = broadcastName;
        this.programInfo = programInfo;
        this.connected = connected;
    }

    public int getIdentifier() {
        return identifier;
    }

    @Nullable
    public String getBroadcastAddress() {
        if (broadcastAddressBytes != null) {
            return String.format(
                    "%02X:%02X:%02X:%02X:%02X:%02X",
                    broadcastAddressBytes[0],
                    broadcastAddressBytes[1],
                    broadcastAddressBytes[2],
                    broadcastAddressBytes[3],
                    broadcastAddressBytes[4],
                    broadcastAddressBytes[5]
            );
        } else {
            return null;
        }
    }

    @Nullable
    public Integer getRssi() {
        return rssi;
    }

    @Nullable
    public String getBroadcastName() {
        return broadcastName;
    }

    @Nullable
    public String getProgramInfo() {
        return programInfo;
    }

    @Nullable
    public Boolean isConnected() {
        return connected;
    }
}
